<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function $(id){
            return document.getElementById(id);
        }
        function submitForm(pn){
            $("pageNO").value = pn;
            $("f1").submit();
        }
    </script>
</head>
<body>
    <div th:if="${session.loginUser == null}">
        请先<a href="/login.html">登陆</a>
    </div>
    <div th:if="${session.loginUser != null}">
        欢迎光临，<span th:text="${session.loginUser.name}"></span>
    </div>

    <div style="display: flex"  th:if="${pg != null}">

        <div style="width: 300px;height: 300px"
        th:each="p : ${pg.records}">
            <img th:src="'/productImg/'+${p.imgPath}" width="200" height="200"><br>
            商品名：<span th:text="${p.name}"></span><br>
            单价：<span th:text="${p.price}"></span><br>
            评论数量：<span th:text="${p.speakNum}"></span><br>
            <a th:href="@{/product/findById(id=${p.id})}">查看</a>
        </div>
    </div>

    <div th:if="${pg != null}">
        <a th:each="i : ${#numbers.sequence(1,pg.pages)}" th:text="${i}" style="margin-left: 10px;"
        th:href="'javascript:submitForm('+${i}+')'"></a>
    </div>

    <form action="/product/findByItem" id="f1">
        <input type="hidden" name="pageNO" id="pageNO">
        商品名：<input type="text" name="name" id="name" th:value="${name}"><br>
        <input type="submit" value="提交">
    </form>

</body>
</html>